set box_l   10.7437
set density 0.3

setmd time_step 0.01
setmd skin      0.4
thermostat langevin 1.0 1.0

# warmup integration (with capped LJ potential)
set warm_steps   100
set warm_n_times 30
# do the warmup until the particles have at least the distance min__dist
set min_dist     0.9

# integration
set int_steps    1000
set int_n_times  100


setmd box_l $box_l $box_l $box_l

inter 0 0 lennard-jones 1.0 1.0 1.3


# Particle setup
#############################################################

set volume [expr $box_l*$box_l*$box_l]
set n_part [expr floor($volume*$density)]

for {set i 0} { $i < $n_part } {incr i} {
    set posx [expr $box_l*[t_random]]
    set posy [expr $box_l*[t_random]]
    set posz [expr $box_l*[t_random]]
 
    part $i pos $posx $posy $posz type 0
}

set act_min_dist [analyze mindist]
puts "Start with minimal distance $act_min_dist"
setmd max_num_cells 2744

#############################################################
#  Warmup Integration                                       #
#############################################################

# set LJ cap
set cap 20
inter ljforcecap $cap

# Warmup Integration Loop
set i 0
while { $i < $warm_n_times && $act_min_dist < $min_dist } {

    integrate $warm_steps

    # Warmup criterion
    set act_min_dist [analyze mindist]

#   Increase LJ cap
    set cap [expr $cap+10]
    inter ljforcecap $cap
    incr i
}
puts "Start with minimal distance $act_min_dist"

#############################################################
#      Integration                                          #
#############################################################
inter ljforcecap 0
puts [analyze energy]
set j 0
for {set i 0} { $i < $int_n_times } { incr i} {

    integrate $int_steps
	puts [analyze energy]
}

exit